#include <STC89C5xRC.H>
void Delayms(unsigned int xms)		//@11.0592MHz
{
	unsigned char i, j;
  while(xms)
	{
		i = 2;
		j = 199;
		do
		{
			while (--j);
		} while (--i);
		xms--;
	}
}

unsigned char led = 0;

void main()
{
	P2 = ~0x01;
	while(1)
	{
		if(P31 == 0)
		{
			Delayms(20);
			while(P31 == 0);
			Delayms(20);
			
			led++;
			if(led>=8)
				led = 0;
			P2 = ~(0x01<<led);

		}
		if(P30 == 0)
		{
			Delayms(20);
			while(P30 == 0);
			Delayms(20);
			if(led ==0)
				led = 7;
			else
				led--;
			P2 = ~(0x01<<led);

		}

	}
}